package offer;

import java.util.ArrayList;

public class offerII_0027 {
    public boolean isPalindrome(ListNode head) {
        ArrayList<Integer> list=new ArrayList<>();
        ListNode p=head;
        while(p!=null) {
            list.add(p.val);
            p=p.next;

        }
        int len=list.size();
        int left=0;
        int right=len-1;
        while(left<right){
            if(list.get(left)!=list.get(right)) return false;
            left++;
            right--;
        }
        return true;
    }
}
